package com.example.web;

import com.example.config.School;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

@Controller
@SuppressWarnings("all")
//@RestController  相当于@controller+@responsebody
public class IndexController {
    @Autowired
    private School s;
/*    @Autowired
     *操作redis的模版对象
    private RedisTemplate<Object,Object> redisTemplate;*/
   /*

    @Value("${xpp}")
    private String xpp;
    @Value("${monster}")
    private String monster;*/
    @Transactional//事务的管理
    @RequestMapping("/springboot/say")
    public @ResponseBody String say(){
        System.out.println(s.getName());
        return "Hello,SpringBoot";
    }
    @RequestMapping("/say")
    public ModelAndView sayH(){
        ModelAndView mv = new ModelAndView();
        mv.addObject("message","hello");
        mv.setViewName("say");
        return mv;
    }
    @RequestMapping("/world")
    public String sayW(Model model){
        model.addAttribute("message","world");
        return "say";
    }
}
